 var id = getvl("id");
 var currentPage=1;
 $(function(){
 	   if(id!=null){
 	   	  huoqu();
 	   }else{
 	   	alert("登录异常...");
 	   }
 });
 var ss=1;
function huoqu(){     
		if(currentPage==1 ||currentPage==2|| ss!=0){
		$.ajax({
 url: urlcore + "/api/focusShop/selectPage2?current="+currentPage+"&userId="+id,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
						$.each(data.data.list,function(y,n){
			var dianpuguanzhu='<div class="buy_wode_guanzhu">'+
		'<a href="../6.0.0dianpu.html?id='+n.shop.id+'">'+
			'<dl class="clearfix">'+
				'<dt>'+
					'<img onerror="errorImg(this)" src="'+n.shop.headImg+'" />'+
				'</dt>'+
				'<dd>'+
					'<h5>'+n.shop.storeName+'</h5>'+
					'<p><img src="../images/dizhi.png"/>'+n.shop.address+'</p>'+
				'</dd>'+
			'</dl>'+
		'</a>';
		//<!--删除-->
		if($(".p_header_right").html()=="编辑"){
			dianpuguanzhu+='<div class="public_radio buy_wode_guanzhu_radio" name="1" onclick="xuanzhong(this)" id="tupian">'+
			'<div class="public_select">'+
			 '<input type="checkbox" id="zhi" style="display: none;" value="'+n.id+'"/>'+
	            '<img src="../images/public_radio_default_hui.png">'+
	        '</div>'+
		'</div>';
		}else{
				dianpuguanzhu+='<div class="public_radio buy_wode_guanzhu_radio" name="1" onclick="xuanzhong(this)" id="tupian">'+
			'<div class="public_select">'+
			 '<input type="checkbox" id="zhi" style="display: none;" value="'+n.id+'"/>'+
	            '<img src="../images/public_radio_default_hui.png">'+
	        '</div>'+
		'</div>';
		}
	dianpuguanzhu+='</div>';
	             $("#dianpuguanzhu").append(dianpuguanzhu);
	     
						});
						
						        
$(function(){
	//编辑
	$('.p_header_right').on('click',function(){
		$(".p_header_right").html('删除');
		$("#quxiao").show();
		$("#back").hide(); 
		$(".public_radio").css("display","block")			
	});	
	$('.p_header_left').on('click',function(){
		$(".p_header_right").html('编辑');
		$("#quxiao").hide();
		$("#back").show(); 
		$(".public_radio").css("display","none")			
	});	
	//点击选中

})
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					//alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "../1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});
	}
}
 
 	
 	 	
 	 	function xuanzhong(te){
 	 		if($(te).attr("name")==1){
 	 			$(te).attr("name",2);
 	 			$(te).find("input").attr("checked","checked");
			$(te).find("img").attr("src","../images/public_radio_selcet.png");
 	 		}else{
 	 			$(te).attr("name",1);
 	 			$(te).find("input").removeAttr("checked");
			$(te).find("img").attr("src","../images/public_radio_default_hui.png");	
 	 		}
 	 	}
 	
		
	
 //数组list
function shanchu(){
	    var list=[];
	    
	$("input:checked").each(function(y,n){
		var shopid=$(this).val();
		    list.push({
		    	id:shopid
		    });
		    
	});
		 if(list.length==0){
		 	//alert("未选择")
		 }else{
		 	
		 	 $.ajax({
		url: urlcore + "/api/focusShop/Unfollow",
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify(list),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
		     var sss= window.location.href;
		     window.location.href=sss;
}
		},
		error: function() {
			alert("error");
		}
	});
		 }
    	
    
	
}
 